import { Component, Fragment } from 'react'
import { View, Text, Image } from '@tarojs/components'
import { AtList, AtListItem } from "taro-ui"
import Taro from '@tarojs/taro'
import React from 'react';

class MyList extends Component{
  
    constructor (props) {
        super(props);
        this.state={
          infolist:[]
        }
      }
      //跳转页面
       //声明跳转函数
       onJump(jumpurl){
        Taro.navigateTo({url:jumpurl});
      }
      componentWillMount () { }

      componentDidMount () { 
      //使用axios完成ajax数据请求
         console.log('1111111111111111111111111111111')
         Taro.request({
          method:'GET',
          url:'http://rap2api.taobao.org/app/mock/288481/zyy/test',
          header: {
            'content-type': 'application/json' // 默认值
          },
          success:(res)=>{
            console.log(res.data.infolist)
            this.setState({
              infolist:res.data.infolist
            })
          },
          fail:function(errMsg){
            Taro.showToast({
              title:'服务器请求错误'
            })
          }
         })
         console.log('22222222222222222222222');
      }
    
      componentWillUnmount () { }
    
      componentDidShow () { }
    
      componentDidHide () { }
      
      render(){
      
          return(
            
            <View>
                <View className='at-row'>
                    <Image style='height:100px; width: 100%;' src={require("../../assets/images/redian.png") }/>
                </View>
            <AtList>
              <AtListItem title='' arrow='right' extraText='更多'  onClick={this.onJump.bind(this,'jumppages/page4')}></AtListItem>
              {
                this.state.infolist.map((item,index)=>{
                    return(
                      <AtListItem
                      title={item.titles}
                      note={item.notes}
                      extraText={item.extraTexts}
                      key={index}
                      hasBorder={false}
                      thumb={require("../../assets/images/u183.png")} 
                      onClick={this.onJump.bind(this,'jumppages/page4')}
                      ></AtListItem>
                    )
                })
              }
            </AtList>
            
      </View>
          )
      }
}
export default MyList